package com.guangzhi.weijianzhi.mainhome;


import java.util.Calendar;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.DatePicker.OnDateChangedListener;
import android.widget.EditText;
import android.widget.TimePicker;
import android.widget.TimePicker.OnTimeChangedListener;
import android.widget.Toast;

import com.guangzhi.weijianzhi.R;
import com.guangzhi.weijianzhi.activity.BaseActivity;

public class dddddd extends BaseActivity implements android.view.View.OnClickListener {
    private EditText dateEt=null;
    private EditText timeEt=null;
    private Button button1,button2,button3,button4,button6,button7,button8,button9;
    ProgressDialog progressDialog=null;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dddd_layout);
        dateEt=(EditText)findViewById(R.id.dateEt);
        timeEt=(EditText)findViewById(R.id.timeEt);
        button1=(Button)findViewById(R.id.button1);
        button2=(Button)findViewById(R.id.button2);
        button3=(Button)findViewById(R.id.button3);
        button4=(Button)findViewById(R.id.button4);
        button6=(Button)findViewById(R.id.button6);
        button7=(Button)findViewById(R.id.button7);
        button8=(Button)findViewById(R.id.button8);//
        button9=(Button)findViewById(R.id.button9);
   
        button1.setOnClickListener(this);
        button2.setOnClickListener(this);
        button3.setOnClickListener(this);
        button4.setOnClickListener(this);
        button6.setOnClickListener(this);
        button7.setOnClickListener(this);
        button8.setOnClickListener(this);
        button9.setOnClickListener(this);
        
        
        
        
        
        DatePicker datePicker=(DatePicker)findViewById(R.id.datePicker);
        TimePicker timePicker=(TimePicker)findViewById(R.id.timePicker);
        
        Calendar calendar=Calendar.getInstance();
        int year=calendar.get(Calendar.YEAR);
        int monthOfYear=calendar.get(Calendar.MONTH);
        int dayOfMonth=calendar.get(Calendar.DAY_OF_MONTH);
        datePicker.init(year, monthOfYear, dayOfMonth, new OnDateChangedListener(){

            public void onDateChanged(DatePicker view, int year,
                    int monthOfYear, int dayOfMonth) {
                dateEt.setText("您选择的日期是："+year+"年"+(monthOfYear+1)+"月"+dayOfMonth+"日。");
            }
            
        });
        
        timePicker.setOnTimeChangedListener(new OnTimeChangedListener(){

            public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
                timeEt.setText("您选择的时间是："+hourOfDay+"时"+minute+"分。");
            }
            
        });
    }
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub

        final String[] itemStrings={"AA","BB","CC","DD"};
       // , android.view.View.OnClickListenerTODO Auto-generated method stub
       switch (v.getId()) {
       case R.id.button1:
            AlertDialog.Builder dialog=new AlertDialog.Builder(dddddd.this);
              dialog.setTitle("Dialog").setIcon(android.R.drawable.ic_dialog_info).setMessage("弹出框").setPositiveButton("确定", new DialogInterface.OnClickListener() {
                
               @Override
               public void onClick(DialogInterface dialog, int which) {
                   //转跳到另外一个Activity
                   // TODO Auto-generated method stub
//                   Intent intent=new Intent();
//               //    intent.setClass(getApplicationContext(), list.class);
//                   startActivity(intent);
               }
           }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
                
                
               public void onClick(DialogInterface dialog, int which) {
                   // TODO Auto-generated method stub
                   dialog.cancel();//取消弹出框
               }
           }).create().show();
           break;
       case R.id.button2:
            
           AlertDialog.Builder builder=new AlertDialog.Builder(dddddd.this);
           builder.setTitle("LIST").setIcon(android.R.drawable.ic_lock_lock).setItems(itemStrings, new DialogInterface.OnClickListener() {
                
               @Override
               public void onClick(DialogInterface dialog, int which) {
                   // TODO Auto-generated method stub
               Toast.makeText(getApplicationContext(), "你点击的是"+itemStrings[which], Toast.LENGTH_LONG).show(); 
               }
           }).create().show();
           break;
       case R.id.button3:
            
           AlertDialog.Builder builder1=new AlertDialog.Builder(dddddd.this);
           builder1.setTitle("LIST").setIcon(android.R.drawable.ic_lock_lock).setSingleChoiceItems(itemStrings,-1, new DialogInterface.OnClickListener() {
                
               @Override
               public void onClick(DialogInterface dialog, int which) {
                   // TODO Auto-generated method stub
               Toast.makeText(getApplicationContext(), "你点击的是"+itemStrings[which], Toast.LENGTH_LONG).show(); 
                
               }
           }).setPositiveButton("确定" , null) .create().show();
           builder1.setCancelable(true);
           break;
           case R.id.button4:
               progressDialog=ProgressDialog.show(dddddd.this, "下载", "下载中.....",true);
               progressDialog.setCancelable(true);//当点击按钮返回的时候Dialog消失
               //progressDialog.dismiss();
               break;
                
           case R.id.button6:
             /*  LayoutInflater inflater=(LayoutInflater)getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
               View view=inflater.inflate(R.layout.style, null);
               AlertDialog.Builder builder2=new AlertDialog.Builder(dddddd.this);
               builder2.setView(view);
               builder2.setTitle("QQ2011").setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    
                   @Override
                   public void onClick(DialogInterface dialog, int which) {
                       // TODO Auto-generated method stub
                       dialog.cancel();
                   }
               }).create().show();*/
               
               break;
           case R.id.button7:
        	   new  AlertDialog.Builder(this)    
        	     
        	                   .setTitle("标题" )  
        	      
        	                   .setMessage("简单消息框" )  
        	      
        	                   .setPositiveButton("确定" ,  null )  
        	     
        	                   .show();  
                   break;
           case R.id.button8:
        	   new  AlertDialog.Builder(this)  
        	   .setTitle("请输入" )  
        	   .setIcon(android.R.drawable.ic_dialog_info)  
        	   .setView(new  EditText(this))  
        	   .setPositiveButton("确定" , null)  
        	   .setNegativeButton("取消" ,  null )  
        	   .show();
        	   break;
           case R.id.button9:
        	   new  AlertDialog.Builder(this)  
        	   .setTitle("多选框" )  
        	   .setMultiChoiceItems(new  String[] {"选项1", "选项2", "选项3" , "选项4" },  null ,  null )  
        	   .setPositiveButton("确定" , null)                  
        	   .setNegativeButton("取消" ,  null )  
        	   .show(); 
        	   break;
      
       }
   
	}
    
    
}